package com.yh.serviceimpl;



import com.yh.dao.StudentDao;
import com.yh.dao.TeacherDao;
import com.yh.daoimpl.StudentDaoImpl;
import com.yh.daoimpl.TeacherDaoImpl;
import com.yh.javabean.Student;
import com.yh.javabean.Teacher;
import com.yh.service.StudentService;

import java.util.ArrayList;

/**
 * @Auther: Liang
 * @Date: 2024/4/2 - 04 - 02 - 10:30
 * @Description: com.sms.serviceimpl
 * @version: 1.0
 */
public class StudentServiceImpl implements StudentService {
    //现将当前服务需要操作的数据库对应的dao创建
    StudentDao studentDao = new StudentDaoImpl();
    TeacherDao teacherDao = new TeacherDaoImpl();

    @Override
    public ArrayList<Teacher> lookAllTeacher() {
        return teacherDao.selectAll();
    }

    @Override
    public void selectTeacher(int sid, int tid) {
        studentDao.updateTidBysid(sid, tid);
    }

    @Override
    public Student myinfo(int sid) {
        ArrayList<Student> students = studentDao.selectBysid(sid);
        if (students.isEmpty()) {
            return null;
        }
        return students.get(0);
    }

    @Override
    public void restPassword(int sid, String password) {
        studentDao.updatePasswordBySid(sid, password);
    }
}
